

<hr>

{volist name="list1" id="item1"}
<div class="accordion" id="category_{$item1.id}" role="tablist" aria-multiselectable="true">
    <div class="panel" style="background: none; border: none; -webkit-box-shadow: none; box-shadow: none;">
        <div class="panel-heading" style="background: none; border: 1px solid #ebebeb;">
            <i class="fa fa-plus" role="tab" id="category_header_{$item1.id}" data-toggle="collapse"
               data-parent="#category_{$item1.id}" href="#category_collapse_{$item1.id}"
               aria-expanded="false" aria-controls="category_collapse_{$item1.id}"
               onclick="collapseCategory('category_header_{$item1.id}')"></i>
            <span class="panel-title">【ID：{$item1.id}】{$item1.title}</span>
            <div style="float: right; margin-top: -4px;">
                {if $item1["is_visible"]}
                <label class="label label-success" data-toggle="ajaxSwitch" data-switch-status="1"
                       data-switch-value-0="1|显示|label label-success|{:url('Region/visible',array('cid'=>$item1['id'],'status'=>1))}"
                       data-switch-value-1="0|隐藏|label label-warning|{:url('Region/visible',array('cid'=>$item1['id'],'status'=>0))}">显示</label>
                {else}
                <label class="label label-warning" data-toggle="ajaxSwitch" data-switch-status="0"
                       data-switch-value-0="1|显示|label label-success|{:url('Region/visible',array('cid'=>$item1['id'],'status'=>1))}"
                       data-switch-value-1="0|隐藏|label label-warning|{:url('Region/visible',array('cid'=>$item1['id'],'status'=>0))}">隐藏</label>
                {/if}

                <!--禁用添加二级分类的功能-->

                <button type="button" class="btn btn-default btn-sm" onclick="modal('{:url(\'edit\',array(\'cid\'=>$item1[\'id\']))}','编辑省份')">
                    <i class="fa fa-edit"></i>
                </button>

            </div>
        </div>
        <div id="category_collapse_{$item1.id}" class="panel-collapse collapse" role="tabpanel"
             aria-labelledby="category_header_{$item1.id}">
            <div class="panel-body" style="padding-right: 0;">
                {if condition="!empty($item1.children)"}
                {volist name="$item1.children" id="item2"}
                <div class="accordion" id="category_{$item2.id}" role="tablist" aria-multiselectable="true">
                    <div class="panel" style="background: none; border: none; -webkit-box-shadow: none; box-shadow: none;">
                        <div class="panel-heading" style="background: none; border: 1px solid #ebebeb;">
                            <!--<i class="fa fa-minus" role="tab" id="category_header_{$item2.id}" data-toggle="collapse"-->
                               <!--data-parent="#category_{$item2.id}" href="#category_collapse_{$item2.id}"-->
                               <!--aria-expanded="true" aria-controls="category_collapse_{$item2.id}"-->
                               <!--onclick="collapseCategory('category_header_{$item2.id}')"></i>-->
                            <span class="panel-title">【ID：{$item2.id}】{$item2.title}</span>
                            <div style="float: right; margin-top: -4px;">
                                {if $item2["is_visible"]}
                                <label class="label label-success" data-toggle="ajaxSwitch" data-switch-status="1"
                                       data-switch-value-0="1|显示|label label-success|{:url('Region/visible',array('cid'=>$item2['id'],'status'=>1))}"
                                       data-switch-value-1="0|隐藏|label label-warning|{:url('Region/visible',array('cid'=>$item2['id'],'status'=>0))}">显示</label>
                                {else}
                                <label class="label label-warning" data-toggle="ajaxSwitch" data-switch-status="0"
                                       data-switch-value-0="1|显示|label label-success|{:url('Region/visible',array('cid'=>$item2['id'],'status'=>1))}"
                                       data-switch-value-1="0|隐藏|label label-warning|{:url('Region/visible',array('cid'=>$item2['id'],'status'=>0))}">隐藏</label>
                                {/if}

                                <button type="button" class="btn btn-default btn-sm" onclick="modal('{:url(\'edit\',array(\'cid\'=>$item2[\'id\']))}','编辑城市')">
                                    <i class="fa fa-edit"></i>
                                </button>

                            </div>
                        </div>

                    </div>
                </div>
                {/volist}
                {/if}
            </div>
        </div>
    </div>
</div>
{/volist}

<script>
    function collapseCategory(objectId)
    {
        var object = $("#"+objectId);
        //减号变加号
        if (object.hasClass("fa-minus"))
        {
            object.removeClass("fa-minus");
            object.addClass("fa-plus");
        }
        //加号变减号
        else if (object.hasClass("fa-plus"))
        {
            object.removeClass("fa-plus");
            object.addClass("fa-minus");
        }
    }
</script>